package com.treehole.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

//import com.alibaba.fastjson.JSON;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.treehole.model.TextContent;
import com.treehole.service.impl.TextContentServiceImpl;

public class IndexAction extends ActionSupport {

	private TextContentServiceImpl<TextContent> textContentService;
	
	@Override
	public String execute() throws Exception {
		List<TextContent> tmpList = textContentService.listAll(new TextContent());
		
		//String jsonString = JSON.toJSONString(tmpList);
		
		ActionContext ctx = ActionContext.getContext();             
		HttpServletRequest request = (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST); 
		request.setAttribute("tmpList", tmpList);
		//request.setAttribute("jsonString", jsonString);
		return SUCCESS;
	}

	public void setTextContentService(
			TextContentServiceImpl<TextContent> textContentService) {
		this.textContentService = textContentService;
	}

}
